package com.example.demo.model;

import com.example.demo.dataobject.ProductDetailDO;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 商品详情
 */
public class ProductDetail implements Serializable {
    private String id;//主键
    private String productId;//关联商品
    private Double price;//价格
    private Double size;//尺码
    private Integer stock;//库存
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtCreated;//创建时间
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtModified;//修改时间

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getSize() {
        return size;
    }

    public void setSize(Double size) {
        this.size = size;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public LocalDateTime getGmtCreated() {
        return gmtCreated;
    }

    public void setGmtCreated(LocalDateTime gmtCreated) {
        this.gmtCreated = gmtCreated;
    }

    public LocalDateTime getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(LocalDateTime gmtModified) {
        this.gmtModified = gmtModified;
    }

    /**
     * 模型转换成数据库对象
     * @return ProductDetailDO商品数据库对象
     */
    public ProductDetailDO toDO(){
        ProductDetailDO productDetailDO = new ProductDetailDO();
        productDetailDO.setId(id);
        productDetailDO.setProductId(productId);
        productDetailDO.setPrice(price);
        productDetailDO.setSize(size);
        productDetailDO.setStock(stock);
        productDetailDO.setGmtCreated(gmtCreated);
        productDetailDO.setGmtModified(gmtModified);
        return productDetailDO;
    }
}
